<template>
  <div class="New_build2">
    <!-- 这里是查询的补单 -->
    <div class="mask"></div>
    <div class="new_build1">
      <div class="build-top">
        <p>补单（仓库调拨查询）</p>
        <i class="el-icon-close" @click="closeSporder"></i>
      </div>
      <div class="build-info">
        <div class="build-info-1">
          <p>调拨日期</p>
          <el-date-picker style="width: 170px" v-model="allotTime" type="date">
          </el-date-picker>
          <p>调入仓库</p>
          <el-input
            v-model="foldWarehouse"
            style="width: 60px; margin-right: 10px"
            @blur="foldWarehouseBlur"
          ></el-input>
          <div class="ck">
            <el-select
              style="width: 100px"
              v-model="foldWarehouseName"
              @change="queryNo"
              placeholder="请选择"
            >
              <el-option
                v-for="item in foldWarehouseList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </div>

          <p>调出仓库</p>
          <el-input
            v-model="calloutWarehouse"
            style="width: 60px; margin-right: 10px"
            @blur="calloutWarehouseBlur"
            id="input"
          ></el-input>
          <div class="ck">
            <el-select
              style="width: 100px"
              v-model="calloutWarehouseName"
              @change="queryNo1"
              placeholder="请选择"
            >
              <el-option
                v-for="item in calloutWarehouseList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </div>

          <!-- <p>款号</p>
          <el-input class="build-inp"></el-input> -->
        </div>
        <div class="build-info2">
          <p>品名</p>
          <el-input
            style="width: 170px"
            v-model="commodityName"
            disabled
          ></el-input>
          <p>调拨序号</p>
          <el-input
            style="width: 170px"
            v-model="allotSequence"
            disabled
          ></el-input>
          <p>售价</p>
          <el-input
            style="width: 170px"
            v-model="sellingPrice"
            disabled
          ></el-input>
          <p>备注</p>
          <el-input style="width: 160px" v-model="remark"></el-input>
        </div>

        <div class="build-info-4">
          <el-table
            border
            :data="codeData"
            id="codeTable"
            style="width: 100%; margin-bottom: 20px"
            max-height="160px"
            :header-cell-style="{
              background: '#f4f4f4',
              padding: 0,
              height: '40px'
            }"
            :cell-style="{ padding: 0, height: '36px' }"
          >
            <el-table-column :label="header"> </el-table-column>
            <el-table-column prop="colorName" label="颜色"> </el-table-column>
            <!-- <el-table-column
              prop="colorNo"
              label="颜色編號">
            </el-table-column> -->

            <template v-for="col in sizeList">
              <el-table-column
                :key="col + Math.random()"
                :prop="col"
                :label="col"
              >
                <template slot-scope="scope">
                  <!-- <el-form :v-model="scope.row"> -->
                  <!-- <el-form-item> -->
                  <!-- <el-input v-model="scope.row[col]" @blur="handleClick(scope.$index,scope.row[col])" ></el-input>
                    <span>{{scope.row[col]}}</span> -->
                  <!-- </el-form-item> -->
                  <!-- </el-form> -->

                  <el-input
                    size="small"
                    class="innerInp"
                    v-model="scope.row[col]"
                    @blur="
                      handleClick($event, {
                        index: scope.$index,
                        key: col,
                        result: scope.row[col]
                      })
                    "
                    @keyup.enter.native="inpEnter"
                  >
                  </el-input>
                </template>
              </el-table-column>
            </template>
          </el-table>
        </div>

        <!-- <div class="barcode">
          <p>条码扫描</p>
          <el-switch
            v-model="isBarcode"
            active-color="#409EFF"
            inactive-color="#C0C4CC"
          >
          </el-switch>
        </div> -->

        <!-- <div class="chose">
          <p>条码扫描</p>
          <el-radio :disabled="!isBarcode" v-model="radio" label="1"
            >货号码</el-radio
          >
          <el-radio :disabled="!isBarcode" v-model="radio" label="2"
            >ID码</el-radio
          >
          <i
            class="el-icon-question"
            style="color: #017aff; margin: 4px 6px 0 15px"
          ></i>
          <p>冲减单子. 点"款号"， 请按F7，把数量填成-1</p>
        </div> -->

        <div class="enterBarcode">
          <el-input
            v-model="searchValue"
            placeholder="扫描/输入条码，输完按回车"
            id="input2"
            @keyup.enter.native="barcodeEnter1($event)"
          ></el-input>
          <!-- <el-input placeholder="不一致的情况手输货号，输完按回车"></el-input> -->
        </div>

        <el-table
          :height="codeData.length === 0 ? '276px' : '210px'"
          :data="barcodeData"
          highlight-current-row
          @row-click="rowClick"
          style="width: 100%"
          :header-cell-style="{
            background: '#f4f4f4',
            padding: 0,
            height: '40px'
          }"
          :cell-style="{ padding: 0, height: '36px' }"
        >
          <el-table-column
            prop="kindsNumber"
            show-overflow-tooltip
            label="款号"
          >
          </el-table-column>
          <el-table-column prop="colorName" label="颜色"> </el-table-column>
          <el-table-column prop="sizeNo" label="尺码编号"> </el-table-column>
          <el-table-column prop="sum" label="数量"> </el-table-column>
          <el-table-column prop="onePrice" label="单价"> </el-table-column>
          <el-table-column prop="sellingPrice" label="售价"> </el-table-column>
          <el-table-column prop="commodityName" label="品名"> </el-table-column>
        </el-table>
      </div>

      <div class="build-btn">
        <div style="margin: 5px 20px 0 0">
          <el-button @click="closeSporder">取消</el-button>
          <el-button type="primary" @click="saveSporder">继续录入</el-button>
          <!-- <el-button type="primary" @click="keepGoing">继续录入</el-button> -->
        </div>
      </div>
    </div>

    <!-- F7弹出框 -->
    <div class="popup" :style="{ display: showPopup }">
      <div class="popup_t">
        <p>输入扫描数量</p>
        <i @click="closePopup" class="el-icon-close"></i>
      </div>
      <div class="popup_c">
        <p>请输入扫描数量</p>
        <p>如果不输入则扫描数量为1</p>
        <el-input
          v-model="scanNum"
          style="margin-top: 10px"
          @keyup.enter="determine"
        ></el-input>
        <!-- <input type="text" 
            class="popup_button" 
            v-model="scanNum"
            @keyup.enter="determine"> -->
      </div>
      <div class="popup_b">
        <el-button @click="closePopup">取消</el-button>
        <el-button type="primary" @click="determine">确定</el-button>
      </div>
    </div>
  </div>
</template>

<script>
// import { kindsNumberOutContinue, kindsNumberOut } from '../../../../network/customerOutTotal'
import {
  getScanning,
  getBarCode,
  getKind
} from '../../../../network/manufacturer'
import { getKindsNumberList } from '../../../../network/artNo'
import { getNumber } from '../../../../network/customerOutTotal'
import { AddWarehouse } from '../../../../network/manufacturer'
export default {
  props: [
    'warehouseData',
    'showData',
    'tab1Data',
    'kindList',
    'kindList1',
    'remarks'
  ],

  created() {
    console.log(this.calloutWarehouseBlur)
  },
  data() {
    return {
      sizeList: [],
      Rid: [],
      findList: [],
      // details:[],
      scanNum: 1,
      foldWarehouse: '',
      foldWarehouseName: '',
      foldWarehouseList: [],
      calloutWarehouse: '',
      calloutWarehouseName: '',
      calloutWarehouseList: [],

      cols: [],
      header: '',
      enteringTime: '',
      showPopup: 'none',
      allotTime: new Date(),
      commodityName: '',
      sellingPrice: '',
      allotSequence: '',
      remark: '',

      codeData: [
        {
          color: '红色',
          seven: 2,
          nine: 3,
          isOK: true,
          eleven: 22,
          three: 6,
          five: 1
        }
      ],
      isBarcode: false,
      radio: '1',
      searchValue: '',
      barcodeData: [], // 底部表格数据
      XHList1: [],
      XHList: [],
      barcodeData1: [],
      state: ''
    }
  },
  methods: {
    handleClick(e, { index, key, result }) {
      // let r = /^\+?[1-9][0-9]*$/
      let r = /^(0|[1-9][0-9]*|-[1-9][0-9]*)$/
      if (result != 0) {
        result = result.replace(/\b(0+)/gi, '')
      }
      if (!r.test(result) && result) {
        this.$alert('数量请输入整数', '', {
          confirmButtonText: '确定'
        })
        this.codeData[index][key] = 0
        return
      }
      this.codeData[index][key] = result
    },
    inpEnter(e) {
      e.target.parentNode.parentNode.parentNode.classList.remove('activeCell')
    },
    rowClick(e) {
      // this.details = e
    },
    //条码扫描
    barcodeEnter1() {
      if (this.searchValue) {
        //关闭条码扫描
        if (!this.isBarcode) {
          console.log('条码扫描关')
          // 手输款号
          getKindsNumberList({ kindsNumberStr: this.searchValue }).then(
            (res) => {
              this.XHList = res.data.data.data
              console.log(this.XHList)
              if (res.data.data.data.length) {
                this.header = res.data.data.data[0].styleNumber
                this.$emit('inpNumChange')
                // 品牌公司查条码规律详情
                getBarCode({
                  company: res.data.data.data[0].brandedCompany
                }).then((res) => {
                  // console.log(res)
                  this.manufacturerBarCode = res.data.data[0]
                })
                // console.log(this.manufacturerBarCode)
                // 输入款号显示中间表和尺码信息   ZZZ-AAS
                res.data.data.data.sort((a, b) => {
                  return a.relevanceSize.localeCompare(b.relevanceSize)
                })
                let tmp = res.data.data.data
                this.tmpBarcodeData = tmp
                // console.log(tmp)

                // 中间表  尺码表头
                this.sizeList = [tmp[0].size]
                let isExistSize = 0
                for (const i of tmp) {
                  for (const j of this.sizeList) {
                    if (j == i.size) {
                      isExistSize = 0
                      break
                    }
                    isExistSize = 1
                  }
                  if (isExistSize) {
                    this.sizeList.push(i.size)
                    console.log(this.sizeList)
                  }
                }

                // 中间表
                let tmpCodeData = [
                  { colorNo: tmp[0].colorNo, colorName: tmp[0].colorName }
                ]
                let isExistColor = 0
                for (const i of tmp) {
                  for (const j of tmpCodeData) {
                    if (j.colorName == i.colorName) {
                      isExistColor = 0
                      break
                    }
                    isExistColor = 1
                  }
                  if (isExistColor) {
                    tmpCodeData.push({
                      colorNo: i.colorNo,
                      colorName: i.colorName
                    })
                  }
                }
                tmpCodeData.forEach((e) => {
                  this.sizeList.forEach((f) => {
                    e[f] = ''
                  })
                })
                this.codeData = tmpCodeData
                let codeTable = document.getElementById('codeTable')
                let inputs = codeTable.getElementsByTagName('input')
                // console.log(inputs)
                let int = setInterval(() => {
                  clearInterval(int)
                  inputs[0].focus()
                  inputs[inputs.length - 1].onkeyup = (e) => {
                    if (window.event.keyCode == 13) {
                      this.continueInput()
                      this.codeData = []
                      inputs[inputs.length - 1].onkeyup = () => {}
                    }
                  }
                }, 100)
              } else {
                this.$message('此货号/款号无数据')
                this.$refs.barcodeInput.focus()
              }
            }
          )
        } else {
          //开条码扫描
          if (
            this.allotTime == '' ||
            this.foldWarehouse == '' ||
            this.calloutWarehouse == ''
          ) {
            this.$alert('调拨日期，仓库编号不能为空', '', {
              confirmButtonText: '确定'
            })
            return
          }
          var tf
          if (this.radio == '1') {
            tf = true
          } else {
            tf = false
          }
          let obj2 = {
            isKindsNumber: tf /**/,
            searchValue: this.searchValue
          }
          console.log(obj2)

          getScanning(obj2).then((res) => {
            console.log(res.data)
            this.isDis = true
            if (res.data.data[0] == null) {
              this.$message({
                type: 'warning',
                offset: 400,
                message: '该货号或ID码没有数据'
              })
              return
            }
            if (this.isBarcode && this.radio == '2') {
              var sss = { showCode: this.searchValue }
              this.Rid.push(sss)
            }
            this.AAa = res.data.data
            for (var w in this.AAa) {
              this.AAa[w]['sum'] = this.scanNum
              this.AAa[w]['onePrice'] =
                this.AAa[w].sellingPrice * (this.AAa[w].discount / 10)
              this.AAa[w]['allotTime'] = this.allotTime
              this.AAa[w]['sequence'] = this.sequence
              this.AAa[w]['calloutWarehouse'] = this.calloutWarehouse
              this.AAa[w]['dataSource'] = tf == true ? 1 : 0
              if (tf == false) {
                this.AAa[w]['rfID'] = this.searchValue
              } else {
                this.AAa[w]['kNumber'] = this.searchValue
              }
            }
            console.log(AAa)

            if (this.barcodeData == '') {
              this.barcodeData = this.AAa
            } else {
              this.merge(this.barcodeData, this.AAa)
              // this.AAa为一条数据 两组数据比较 this.barcodeData数组对象里的kindsNumber与this.AAa数组对象里的kindsNumber一样 sum 就相加 else 就push进this.barcodeData
            }

            this.howMany = this.barcodeData.reduce((prev, next) => {
              return prev + next.sum
            }, 0)
            this.searchValue = ''
            document.getElementById('input2').focus()
            console.log(this.barcodeData)
          })
        }
      }
    },
    merge(target, source) {
      const targetIds = target.reduce(
        (res, v) => res.add(v.kindsNumber),
        new Set()
      )
      const sourceIds = source.reduce(
        (res, v) => res.add(v.kindsNumber),
        new Set()
      )
      target.forEach((v) => sourceIds.has(v.kindsNumber) && v.sum++)
      return target.push(...source.filter((v) => !targetIds.has(v.kindsNumber)))
    },

    continueInput() {
      if (
        this.allotTime == '' ||
        this.foldWarehouse == '' ||
        this.calloutWarehouse == ''
      ) {
        this.$message({
          type: 'warning',
          offset: 400,
          message: '调拨日期，仓库编号不能为空'
        })
        return
      }

      let kindsNumberNumMap = {}
      // this.isBarcode被注释掉了，逻辑只走else
      if (this.isBarcode) {
        // 扫描
        if (this.radio == 1) {
          // 扫描货号码
          kindsNumberNumMap[this.searchValue] = this.scanNum
        } else if (this.radio == 2) {
          // 扫描ID码
          searchKindsNumber({
            // 条码与货号是否一致
            isSame: false,
            // 是否开启条码扫描
            isScanner: true,
            searchValue: this.searchValue
          }).then((res) => {
            console.log(res)
            kindsNumberNumMap[res.data.data[0].kindsNumber] = this.scanNum
          })
        }
      } else {
        // 输入
        let knList = []
        this.codeData.forEach((e) => {
          let c = e.colorNo
          this.sizeList.forEach((f) => {
            if (this.manufacturerBarCode.styleColorSize) {
              // 型尺色

              if (this.manufacturerBarCode.styleColor) {
                // 款号与尺码之间有 -

                if (this.manufacturerBarCode.colorSize) {
                  // 色号与尺码之间有 -
                  knList.push({
                    kindsNumber: `${this.header}-${f}-${c}`,
                    sum: e[f]
                  })
                } else {
                  // 色号与尺码之间没有 -
                  knList.push({
                    kindsNumber: `${this.header}-${f}${c}`,
                    sum: e[f]
                  })
                }
              } else {
                // 款号与尺码之间没有 -

                if (this.manufacturerBarCode.colorSize) {
                  // 色号与尺码之间有 -
                  knList.push({
                    kindsNumber: `${this.header}${f}-${c}`,
                    sum: e[f]
                  })
                } else {
                  // 色号与尺码之间没有 -
                  knList.push({
                    kindsNumber: `${this.header}${f}${c}`,
                    sum: e[f]
                  })
                }
              }
            } else {
              // 型色尺

              if (this.manufacturerBarCode.styleColor) {
                // 款号与颜色之间有 -

                if (this.manufacturerBarCode.colorSize) {
                  // 色号与尺码之间有 -
                  knList.push({
                    kindsNumber: `${this.header}-${c}-${f}`,
                    sum: e[f]
                  })
                } else {
                  // 色号与尺码之间没有 -
                  knList.push({
                    kindsNumber: `${this.header}-${c}${f}`,
                    sum: e[f]
                  })
                }
              } else {
                // 款号与颜色之间没有 -

                if (this.manufacturerBarCode.colorSize) {
                  // 色号与尺码之间有 -
                  knList.push({
                    kindsNumber: `${this.header}${c}-${f}`,
                    sum: e[f]
                  })
                } else {
                  // 色号与尺码之间没有 -
                  knList.push({
                    kindsNumber: `${this.header}${c}${f}`,
                    sum: e[f]
                  })
                }
              }
            }
          })
        })
        // console.log('knList111', knList)
        this.XHList1 = knList
        var kindList = {}
        knList.forEach((e) => {
          if (e.sum != '') {
            kindList[e.kindsNumber] = e.sum
          }
        })
        // 这里是拿到拼接好的数据
        console.log('这里显示', kindList)
      }

      //判断库存够不够
      let kindsNumberNumberMap = kindList
      let obj3 = {
        companyNo: this.calloutWarehouse,
        kindsNumberNumberMap
      }
      console.log(obj3)
      getNumber(JSON.stringify(obj3)).then((res) => {
        console.log(res.data)
        if (res.data.code == 202) {
          this.$message.error({
            message: '查无此对象'
          })
          return
        }
        for (var g in this.XHList1) {
          for (let k in res.data.data) {
            if (
              this.XHList1[g].kindsNumber == res.data.data[k] ||
              this.XHList1[g].sum == ''
            ) {
              this.$message.error({
                message: `${res.data.data}'货号库存不够'`
              })
              this.XHList1.splice(g, 1)
              // console.log(this.XHList1)
            }
          }
        }
        // console.log(this.XHList1)
        for (let a in this.XHList1) {
          for (let b in this.XHList) {
            if (this.XHList1[a].kindsNumber == this.XHList[b].kindsNumber) {
              this.XHList[b]['sum'] = this.XHList1[a].sum
              this.XHList[b]['onePrice'] =
                Number(this.XHList[b].sum) * Number(this.XHList[b].sellingPrice)
              this.barcodeData1.push(this.XHList[b])
              // console.log(this.barcodeData1)
            }
          }
        }
        for (let h in this.barcodeData1) {
          if (this.barcodeData1[h].sum == 0) {
            delete this.barcodeData1[h]
          }
        }
        this.eliminate()
      })
    },

    eliminate() {
      //数组对象里 kindsNumber相同  数量相加 合并
      this.state = 1
      console.log(this.barcodeData1)
      var tmp = {}
      for (let u in this.barcodeData1) {
        var key = this.barcodeData1[u].kindsNumber
        // console.log(tmp[key])
        if (tmp[key]) {
          tmp[key].kindsNumber = this.barcodeData1[u].kindsNumber
          tmp[key].sum += Number(this.barcodeData1[u].sum)
          tmp[key].allotSequence = this.allotSequence
          tmp[key].foldWarehouse = this.foldWarehouse
          tmp[key].allotTime = this.allotTime
          // tmp[key].curency = this.barcodeData1[u].curency;
          // tmp[key].differMoney = Number(this.barcodeData1[u].sum)*Number(this.barcodeData1[u].sellingPrice)
          tmp[key].affirm = this.barcodeData1[u].affirm
          tmp[key].id = this.barcodeData1[u].id
          tmp[key].monthly = this.barcodeData1[u].monthly
          tmp[key].onePrice = this.barcodeData1[u].onePrice
          tmp[key].sellingPrice = this.barcodeData1[u].sellingPrice
          tmp[key].softwareCustomerId = this.barcodeData1[u].softwareCustomerId
          tmp[key].calloutWarehouse = this.calloutWarehouse
          tmp[key].colorName = this.barcodeData1[u].colorName
          tmp[key].sizeNo = this.barcodeData1[u].sizeNo
          tmp[key].commodityName = this.barcodeData1[u].commodityName
        } else {
          tmp[key] = {}
          tmp[key].kindsNumber = this.barcodeData1[u].kindsNumber
          tmp[key].sum = Number(this.barcodeData1[u].sum)
          tmp[key].allotSequence = this.allotSequence
          tmp[key].foldWarehouse = this.foldWarehouse
          tmp[key].allotTime = this.allotTime
          // tmp[key].curency = this.barcodeData1[u].curency;
          // tmp[key].differMoney = Number(this.barcodeData1[u].sum)*Number(this.barcodeData1[u].sellingPrice)
          tmp[key].affirm = this.barcodeData1[u].affirm
          tmp[key].id = this.barcodeData1[u].id
          tmp[key].monthly = this.barcodeData1[u].monthly
          tmp[key].onePrice = this.barcodeData1[u].onePrice
          tmp[key].sellingPrice = this.barcodeData1[u].sellingPrice
          tmp[key].softwareCustomerId = this.barcodeData1[u].softwareCustomerId
          tmp[key].calloutWarehouse = this.calloutWarehouse
          tmp[key].colorName = this.barcodeData1[u].colorName
          tmp[key].sizeNo = this.barcodeData1[u].sizeNo
          tmp[key].commodityName = this.barcodeData1[u].commodityName
        }
      }
      this.barcodeData = []
      for (let k in tmp) {
        this.barcodeData.push(tmp[k])
      }
      // for(let h in this.barcodeData){
      //   if(this.barcodeData[h].sum == 0){
      //     delete this.barcodeData[h]
      //   }
      // }
      console.log(this.barcodeData)
    },

    //保存
    saveSporder() {
      if (
        this.allotTime == '' ||
        this.foldWarehouse == '' ||
        this.calloutWarehouse == ''
      ) {
        this.$message({
          type: 'warning',
          message: '调拨日期，仓库编号不能为空'
        })
        return
      }
      /* start开始拼接表格中的字段参数 */
      // 输入
      let knList = []
      this.codeData.forEach((e) => {
        let c = e.colorNo
        this.sizeList.forEach((f) => {
          if (this.manufacturerBarCode.styleColorSize) {
            // 型尺色

            if (this.manufacturerBarCode.styleColor) {
              // 款号与尺码之间有 -

              if (this.manufacturerBarCode.colorSize) {
                // 色号与尺码之间有 -
                knList.push({
                  kindsNumber: `${this.header}-${f}-${c}`,
                  sum: e[f]
                })
              } else {
                // 色号与尺码之间没有 -
                knList.push({
                  kindsNumber: `${this.header}-${f}${c}`,
                  sum: e[f]
                })
              }
            } else {
              // 款号与尺码之间没有 -

              if (this.manufacturerBarCode.colorSize) {
                // 色号与尺码之间有 -
                knList.push({
                  kindsNumber: `${this.header}${f}-${c}`,
                  sum: e[f]
                })
              } else {
                // 色号与尺码之间没有 -
                knList.push({
                  kindsNumber: `${this.header}${f}${c}`,
                  sum: e[f]
                })
              }
            }
          } else {
            // 型色尺

            if (this.manufacturerBarCode.styleColor) {
              // 款号与颜色之间有 -

              if (this.manufacturerBarCode.colorSize) {
                // 色号与尺码之间有 -
                knList.push({
                  kindsNumber: `${this.header}-${c}-${f}`,
                  sum: e[f]
                })
              } else {
                // 色号与尺码之间没有 -
                knList.push({
                  kindsNumber: `${this.header}-${c}${f}`,
                  sum: e[f]
                })
              }
            } else {
              // 款号与颜色之间没有 -

              if (this.manufacturerBarCode.colorSize) {
                // 色号与尺码之间有 -
                knList.push({
                  kindsNumber: `${this.header}${c}-${f}`,
                  sum: e[f]
                })
              } else {
                // 色号与尺码之间没有 -
                knList.push({
                  kindsNumber: `${this.header}${c}${f}`,
                  sum: e[f]
                })
              }
            }
          }
        })
      })
      // console.log('knList111', knList)
      this.XHList1 = knList
      var kindList = {}
      knList.forEach((e) => {
        if (e.sum != '') {
          kindList[e.kindsNumber] = e.sum
        }
      })
      // 这里是拿到拼接好的数据
      console.log('这里显示', kindList)
      /* end这里拼接完成 */
      var ae = []
      var ao = []
      var au = {}
      for (let r of this.barcodeData) {
        ae.push(r.kindsNumber)
        ao.push(r.sum)
        for (var v in ae) {
          for (var b in ao) {
            if (v == b) {
              au[ae[v]] = ao[b]
            }
          }
        }
        console.log(au)
      }

      var ie = []
      var io = []
      var iu = {}
      for (let t of this.barcodeData) {
        ie.push(t.kindsNumber)
        io.push(t.sum)
        console.log(ie, io)
        for (var g in ie) {
          for (var h in io) {
            if (g == h) {
              iu[ie[g]] = io[h] //属性值作为属性名
            }
          }
        }
      }
      let params = {
        allotTime: this.allotTime,
        commodityName: this.commodityName,
        sellingPrice: this.sellingPrice,
        allotSequence: this.allotSequence,
        remark: this.remark,
        foldWarehouse: this.foldWarehouse,
        foldWarehouseName: this.foldWarehouseName,
        calloutWarehouse: this.calloutWarehouse,
        calloutWarehouseName: this.calloutWarehouseName,
        enteringTime: this.enteringTime,
        // kindsNumberMap: iu,
        kindsNumberNumberMap: kindList,
        rfidList: this.Rid,
        alreadyKindsNumberMap: au,
        dataSource: this.radio == '1' ? 1 : 0
      }
      console.log(params)
      /* 子组件直接发起请求，成功之后，再触发父组件的查询 */
      AddWarehouse(params).then((res) => {
        console.log('继续录入后端返回的数据', res.data)
        // 不要关闭对话框
        // this.showsupOd = 'none'

        if (res.data.code == 200) {
          this.$message({
            type: 'success',
            message: '补单保存成功'
          })
          /* 拿到数据,显示在底部表格 */
          this.barcodeData = res.data.data.insertList
          console.log('this.barcodeData', this.barcodeData)
          // 补单这个不用显示，补单的这个回显也是一样的
          // this.sequence = res.data.data.sequence
          // 触发父组件的查询

          this.$emit('saveSporder', params)
        } else {
          this.$message.error({
            message: '补单保存失败'
          })
        }
      })

      // 清空表格数据
      this.codeData = []
      // 清空表格尺码
      this.sizeList = []
      this.state = ''
      // 底部表格数据
      // this.barcodeData = []
      this.allotTime = ''
      this.foldWarehouse = ''
      this.foldWarehouseName = ''
      this.calloutWarehouse = ''
      this.calloutWarehouseName = ''
      this.commodityName = ''
      this.sellingPrice = ''
      this.remark = ''
      this.searchValue = ''
    },

    queryNo() {
      for (let c of this.foldWarehouseList) {
        if (this.foldWarehouseName == c.value) {
          this.foldWarehouse = c.value
          if (this.foldWarehouse == this.calloutWarehouse) {
            this.$message({
              type: 'warning',
              offset: 400,
              message: '调入仓库与调出仓库不能为同一个'
            })
            this.foldWarehouse = ''
            this.foldWarehouseName = ''
          }
          return
        }
      }
    },
    queryNo1() {
      for (let b of this.calloutWarehouseList) {
        if (this.calloutWarehouseName == b.value) {
          this.calloutWarehouse = b.value
          if (this.calloutWarehouse == this.foldWarehouse) {
            this.$message({
              type: 'warning',
              offset: 400,
              message: '调入仓库与调出仓库不能为同一个'
            })
            this.calloutWarehouse = ''
            this.calloutWarehouseName = ''
          }
          return
        }
      }
    },
    // 调入仓库失去焦点
    foldWarehouseBlur() {
      if (this.foldWarehouse != '') {
        for (const i of this.foldWarehouseList) {
          if (this.foldWarehouse == i.value) {
            this.foldWarehouseName = i.label
            return
          }
        }
        this.$message({
          type: 'error',
          message: '未查询到此仓库编号'
        })
        this.foldWarehouse = ''
        this.foldWarehouseName = ''
      } else {
        this.foldWarehouseName = ''
      }
    },
    //调出仓库编号失去焦点
    calloutWarehouseBlur() {
      if (this.calloutWarehouse != '') {
        for (const i of this.calloutWarehouseList) {
          if (this.calloutWarehouse == i.value) {
            this.calloutWarehouseName = i.label
            return
          }
        }
        this.$message({
          type: 'error',
          message: '未查询到此仓库编号'
        })
        this.calloutWarehouse = ''
        this.calloutWarehouseName = ''
      } else {
        this.calloutWarehouseName = ''
      }
    },
    // 点击取消触发的事件
    closeSporder() {
      // 清空中间表
      // this.barcodeData = []
      this.allotTime = ''
      this.foldWarehouse = ''
      this.calloutWarehouse = ''
      this.commodityName = ''
      this.allotSequence = ''
      this.sellingPrice = ''
      this.remark = ''
      this.barcodeData = []
      this.codeData = []
      this.$emit('closeSporder')
      this.state = ''
    },

    //F7
    closePopup() {
      this.barcodeData = []
      this.showPopup = 'none'
    },
    determine() {
      this.scanNum = this.scanNum
      this.showPopup = 'none'
      this.$alert('数量设置成功', '', {
        confirmButtonText: '确定'
      })
    }
  },
  watch: {
    searchValue(a, b) {
      if (a) {
        this.searchValue = a.toUpperCase().trim()
      }
    },
    warehouseData(a, b) {
      console.log(a)
      a.forEach((e) => {
        this.foldWarehouseList.push({ value: e.value, label: e.label })
        this.calloutWarehouseList.push({ value: e.value, label: e.label })
      })
    },
    showData(a, b) {
      this.findList = a.dataList
      this.allotTime = a.allotTime
      this.allotSequence = a.allotSequence
      this.foldWarehouse = a.foldWarehouse
      this.foldWarehouseName = a.foldWarehouseName
      this.calloutWarehouse = a.calloutWarehouse
      this.enteringTime = a.enteringTime
      for (let b of this.calloutWarehouseList) {
        if (this.calloutWarehouse == b.value) {
          this.calloutWarehouseName = b.label
        }
      }
    },
    // 要注释原来的tab1Data，否则底部表格数据在继续录入成功之后，被清掉
    // tab1Data(a, b) {
    //   /* fei */
    //   // console.log(this.tab1Data)
    //   // this.barcodeData = this.tab1Data
    // },
    kindList() {
      if (this.state != 1) {
        let obj = {
          list: JSON.stringify(this.kindList)
            .replace(/\[|]/g, '')
            .replace(/\"|"/g, '')
        }
        console.log(obj)
        getKind(obj).then((res) => {
          console.log(res)
          this.commodityName = res.data.data[0].commodityName
          this.sellingPrice = res.data.data[0].sellingPrice
          for (let v in res.data.data) {
            for (let n in this.kindList1) {
              if (res.data.data[v].kindsNumber == this.kindList1[n].kind) {
                res.data.data[v]['sum'] = this.kindList1[n].num
              }
              this.barcodeData = res.data.data
              this.barcodeData1 = res.data.data
            }
          }
        })
      }
    },
    kindList1() {
      console.log(this.kindList1)
    },
    remarks(a, b) {
      console.log(a)
      this.remark = this.remarks
    }
  }
}
</script>

<style scoped>
.middle {
  padding: 10px 15px;
}
.middle p {
  padding-bottom: 10px;
}
._top {
  display: flex;
  width: 100%;
  height: 40px;
  padding: 10px 15px;
  justify-content: space-between;
  background: #f8f8f8;
  font-weight: 700;
}
/* 新建资料 */
.mask {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: #000;
  opacity: 0.3;
  z-index: 9;
}
.new_build1 {
  position: fixed;
  /* position: relative; */
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  width: 1070px;
  height: 650px;
  z-index: 99;
  background-color: white;
  overflow: auto;
}
.new_build1 .build-top {
  height: 40px;
  background-color: #f8f8f8;
  display: flex;
  justify-content: space-between;
  padding: 10px 15px;
}
.build-top p {
  font-weight: 700;
}

.new_build1 input {
  height: 30px;
  border: buildlid 1px #dcdfe6;
  border-radius: 5px;
  margin-left: 10px;
}
.new_build1 input:focus {
  outline: none;
  border: buildlid 1px #409eff;
}

.build-info {
  padding: 0 15px;
  padding-bottom: 10px;
  /* border-bottom: buildlid #f2f2f2 2px; */
}
.build-info-1 {
  display: flex;
}
.build-info-1 p {
  display: inline-block;
  width: 80px;
  text-align: right;
  margin: 10px 10px 0 0;
}
.barcode {
  display: flex;
  font-weight: 700;
}

.build-info .barcode p {
  display: inline;
  margin-right: 15px;
}
.build-info .barcode div {
  margin-top: 15px;
}

.barcode-info-1 p,
.barcode-info-2 p {
  display: inline-block;
  width: 96px;
  text-align: right;
  margin-right: 9px;
}
.build-info2 {
  display: flex;
  margin: 10px 0;
}
.build-info2 p {
  display: inline-block;
  width: 80px;
  text-align: right;
  margin: 2px 10px 0 0;
}

.colorBox,
.infoBox {
  display: inline;
}

.enterBarcode {
  height: 60px;
  display: flex;
  background-color: #f2f2f2;
  margin: 15px 0;
}

.build-btn {
  text-align: right;
}

.chose {
  display: flex;
  margin: 10px 0;
}
</style>

<style>
.new_build1 .build-info-1 .ck .el-input__inner {
  width: 100px;
}
.new_build1 .build-info-4 .el-table .cell {
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  word-break: break-all;
  line-height: 41px;
  padding-right: 10px;
  height: 40px;
}
.new_build1 .build-info-4 .el-input__inner {
  border: 0px;
}
.new_build1 .build-info-4 .el-input__inner:focus {
  border: 1px solid #017aff;
}
.new_build1 .chose .el-radio {
  margin: 5px 20px 0 10px;
}

/* .new_build1 .build-info-1 .el-input, .new_build1 .build-info-3 .el-input{
    width: 425px;
  } */
.new_build1 .build-info-1 .el-input,
.new_build1 .build-info-2 .el-input {
  margin-top: 10px;
  /* width: 160px; */
}
.new_build1 .el-input__inner {
  height: 30px !important;
}
.new_build1 .el-input__icon {
  line-height: 30px !important;
}
.build-info .barcode .el-switch {
  margin: 0 !important;
}

.new_build1 .enterBarcode .el-input {
  width: 535px;
  margin: 14px 17px;
}

.new_build1 .build-info-1 .el-input,
.new_build1 .build-info-2 .el-input.elinput--suffix {
  width: 90px;
}
</style>
